import 'package:flutter/material.dart';
import 'package:qunaimedical/components/custom_avatar.dart';
import 'package:qunaimedical/models/doctor.dart';

/// 医生简单信息
class DoctorSummaryCard extends StatelessWidget {
  final EdgeInsetsGeometry margin;
  final Doctor item;

  const DoctorSummaryCard({Key key, this.margin, this.item}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: margin,
      child: ClipRRect(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(10),
          topRight: Radius.circular(10),
        ),
        child: Container(
          height: 120,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/images/bg_doctor_card.png"),
              fit: BoxFit.cover,
            ),
          ),
          child: Stack(
            alignment: Alignment.centerLeft,
            children: [
              CustomAvatar(
                margin: EdgeInsets.only(left: 16),
                size: 70,
                avatarUrl: (item?.avatar == null || item.avatar.isEmpty)
                    ? item?.doctorAccount?.avatar
                    : item?.avatar,
              ),
              Positioned(
                right: 16,
                top: 16,
                child: Text(item?.office ?? '',
                    style: TextStyle(color: Colors.white)),
              ),
              Positioned(
                left: 100,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      item?.fullname ?? '',
                      style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 4.0),
                      child: Row(children: [
                        Text(item?.sectionName ?? '',
                            style: TextStyle(color: Colors.white)),
                        Padding(
                          padding: const EdgeInsets.only(left: 8.0),
                          child: Text(item?.professionalName ?? '',
                              style: TextStyle(color: Colors.white)),
                        )
                      ]),
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
